# -*- coding: utf-8 -*-
import os
import time

oldname = 'main.exe'
newname = 'main.txt'
byname = 'main.old'

if os.path.exists(newname):
    #   如果有备用文件，删除
    if os.path.exists(byname):
        os.remove(byname)
        time.sleep(1)
    #   旧文件后缀改为old备用
    if os.path.exists(oldname):
        os.rename(oldname, byname)
        time.sleep(1)
    #   把新文件后缀名改成exe
    os.rename(newname, oldname)
